<?php
declare (strict_types = 1);
/**
 * 管理员
 */
namespace app\common\admin;

use app\common\facade\model\AdminModel;
use app\common\facade\model\AdminDeptModel;

class Depts extends BaseAdmin
{
  /**
   * 部门信息保存添加
   */
  public function deptAddEditSave($param = [])
  {
      $where = [];
      if(isset($param['id'])):
          $where[] = ['id', '=', $param['id']];
          unset($param['id']);
      endif;

      AdminDeptModel::addEditSave($param, $where);
      return true;
  }

  /**
   * 获取部门列表
   */
  public function deptsList()
  {
    return AdminDeptModel::listsAll('', '', 'id DESC');
  }

  /**
   * 部门删除
   */
  public function deptDelete($param = [])
  {
      if(empty($param['id'])) exception('删除失败！');
      $where = [['id', '=', $param['id']]];

      return AdminDeptModel::deleteData($where);
  }
}